
/*
图表: ANDROID IOS LINUX MACOS WEB WINDOWS
https://pub.flutter-io.cn/packages/syncfusion_flutter_charts
dependencies:
  syncfusion_flutter_charts: ^21.2.9
import 'package:syncfusion_flutter_charts/charts.dart';
import 'package:syncfusion_flutter_charts/sparkcharts.dart';

其他:
https://pub.flutter-io.cn/packages/fl_chart
https://pub.flutter-io.cn/packages/d_chart  //传统
https://pub.flutter-io.cn/packages/charts_painter
https://pub.flutter-io.cn/packages/mrx_charts


导图:
流程图: https://pub.flutter-io.cn/packages/flutter_flow_chart
https://pub-web.flutter-io.cn/packages/graphview
https://pub-web.flutter-io.cn/packages/graphite

SfRadialGauge
https://www.syncfusion.com/flutter-widgets/flutter-radial-gauge?utm_source=pubdev&utm_medium=listing&utm_campaign=flutter-charts-pubdev

时间管理
https://www.syncfusion.com/flutter-widgets/flutter-calendar?utm_source=pubdev&utm_medium=listing&utm_campaign=flutter-charts-pubdev
https://help.syncfusion.com/flutter/calendar/overview


签名
https://help.syncfusion.com/flutter/signaturepad/overview
生成二维码
https://help.syncfusion.com/flutter/barcode/overview


 */

import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_charts/charts.dart';
import 'package:xsdk_flutter/xsdk/utils/chart/bean/x_bean_chart_data_item.dart';
import 'package:xsdk_flutter/xsdk/utils/x_utils_color.dart';
import 'package:xsdk_flutter/xsdk/utils/x_utils_number.dart';
import 'package:xsdk_flutter/xsdk/utils/x_utils_string.dart';
import 'package:xsdk_flutter/xsdk/utils/x_utils_style.dart';
import 'package:xsdk_flutter/xsdk/utils/x_utils_widget.dart';

abstract class XChartUtils{

  /*
  SfCartesianChart图表教程:
  https://help.syncfusion.com/flutter/cartesian-charts/overview
  https://help.syncfusion.com/flutter/cartesian-charts/marker-datalabel

  dependencies:
    syncfusion_flutter_charts: ^22.1.39
  import 'package:syncfusion_flutter_charts/charts.dart';

  支持导出图片: https://help.syncfusion.com/flutter/cartesian-charts/export-cartesian-chart
  饼状图
  https://help.syncfusion.com/flutter/circular-charts/overview
  https://help.syncfusion.com/flutter/circular-charts/chart-types/radial-bar-chart

  1.饼状图(实心圆): PieSeries  注意:实测高度210, 可显示6个数据, 同一边支持5个,即每个色块都有提示
  2.空心圆: DoughnutSeries
  3.多层圆环: RadialBarSeries  注意:要多条数据,否则只有一条数据则100%

其他:
https://pub-web.flutter-io.cn/packages/fl_chart
   */
  static Widget getWidgetChart_Circular(
      {
        required List<XCircularChartDataItem> listData,
        required String type,
        double? width,
        double? height,
        EdgeInsets? margin,//getEdgeInsets(left,top,right,bottom) //注意:不能有负数,即不能使用margin左移
        EdgeInsets? padding,
        bool isAnimationBuild=true, //是否动画效果
        bool isEnableLegend=true, // 是否显示示例
        ChartDataLabelPosition chartDataLabelPosition=ChartDataLabelPosition.inside,//色块内容显示在内部
        OverflowMode overflowMode=OverflowMode.trim,
        Widget? customCenterWidget,
        ChartWidgetBuilder? customItemValueShowWidgetBuild,
      }
      ){

    /*
          <CircularSeries>[
          // Render pie chart
          PieSeries<ChartData, String>(
              dataSource: chartData,
              pointColorMapper:(ChartData data,  _) => data.color,
              xValueMapper: (ChartData data, _) => data.x,
              yValueMapper: (ChartData data, _) => data.y
          )
        ]
           */

    List<CircularSeries> list=[];


    if(type=='RadialBarSeries'){
      list.add(
          RadialBarSeries<XCircularChartDataItem,String>(
              dataSource: listData,
              animationDuration: isAnimationBuild? 1500:0,
              xValueMapper: (XCircularChartDataItem item, _) {
                return item.name;
              },
              yValueMapper: (XCircularChartDataItem item, _) {
                return item.value;
              }
          )
      );
    }else if(type=='DoughnutSeries'){
      list.add(
          DoughnutSeries<XCircularChartDataItem,String>(
              dataSource: listData,
              animationDuration: isAnimationBuild? 1500:0,
              xValueMapper: (XCircularChartDataItem item, _) {
                return item.name;
              },
              yValueMapper: (XCircularChartDataItem item, _) {
                return item.value;
              }
          )
      );
    }else{
      list.add(
          PieSeries<XCircularChartDataItem, String>(
            dataSource: listData,
            radius: customItemValueShowWidgetBuild==null?'80%':'60%',
            animationDuration: isAnimationBuild? 1500:0,
            pointColorMapper:(XCircularChartDataItem item,  _) => item.color,
            xValueMapper: (XCircularChartDataItem item, _) => item.name,
            yValueMapper: (XCircularChartDataItem item, _) => item.value,
            //色块数据显示内容:默认显示value%,或者showValue
            dataLabelMapper: (XCircularChartDataItem item, _) => XStringUtils.isEmpty(item.showValue)?'${XNumberUtils.formatDoubleX(item.value)}%':item.showValue,
            dataLabelSettings: DataLabelSettings(
              isVisible: true,
              textStyle:XStyleUtils.textStyle_333_10(),
              //color: XColorUtils.color333333,//背景色(便签)
              //useSeriesColor: true, //背景色(便签)同色块
              labelPosition:chartDataLabelPosition,
              alignment: ChartAlignment.far,
              overflowMode: overflowMode,
              showZeroValue: true,
              labelIntersectAction: LabelIntersectAction.shift,//showZeroValue设置为true,,当item的值为0时,none:显示,shift实测则不显示
              labelAlignment:ChartDataLabelAlignment.auto,
              //自定义色块数据显示内容(不推荐,需要radius缩小才能显示出来,推荐使用使用showValue默认方式显示值,在字符串中可加\n换行)
              builder: customItemValueShowWidgetBuild,
              //引导线
              connectorLineSettings: const ConnectorLineSettings(
                type: ConnectorType.curve,
                //length: '25%'
              ),
            ),
          )
      );
    }


    return XWidgetUtils.getLayoutContainer(
        width: width,
        height: height,
        margin: margin,
        padding: padding,
        child:SfCircularChart(
          series: list,
          legend:!isEnableLegend?const Legend():
          const Legend(
            isVisible: true,
            position:LegendPosition.bottom,
            alignment:ChartAlignment.center,
            // legendItemBuilder: (
            //     String legendText, dynamic series, dynamic point, int seriesIndex){
            //   return Container(
            //       height: 20,
            //       width: 10,
            //       child: Container(child: Text(point.y.toString()))
            //   );
            // }
          ),
          annotations: customCenterWidget==null?null:<CircularChartAnnotation>[
            CircularChartAnnotation(
              widget: customCenterWidget,
            )
          ],
        )
    );
  }

  /*
  柱状图,折线图
  2.支持1条或多条数据,支持混合(折线,状图),支持叠加, 每条数据为一个ChartSeries;
  3.分组柱状图: ColumnSeries:多条数据_分组柱状图(x轴的值一样时,为同一分组,y轴各自独立)
  4.分组叠加柱状图:StackedColumnSeries 多条数据_叠加分组柱状图(x轴的值一样时,为同一分组,y轴叠加显示)
  5.折线图: LineSeries,StepLineSeries,FastLineSeries,SplineSeries
  6.普通柱状图: BarSeries
  柱状范围:RangeColumnSeries
  7.圆点图: ScatterSeries,BubbleSeries
  8.区域折线: AreaSeries RangeAreaSeries,SplineAreaSeries,SplineRangeAreaSeries,StepAreaSeries
  直方图: HistogramSeries
  叠加折线: StackedLineSeries
  叠加区域折线: StackedAreaSeries
  叠加柱状: StackedBarSeries
  100区域叠加折线: StackedArea100Series
  100区域叠加分组柱状: StackedColumn100Series
  100区域叠加柱状: StackedBar100Series
  股票: HiloSeries,CandleSeries
   */

  //x轴的字符串值在每格中间显示,并不在刻度上
  static Widget getWidgetChart_xAxisString(
      {
        required List<XChartItem> listData,
        bool isXYTransposed=false,//XY轴互换位置,横向 //每个item为1条曲线类型
        ChartTitle? chartTitle,//图表图表
        AxisTitle? xAxisTitle,//x轴标签(标题说明)
        AxisTitle? yAxisTitle,//x轴标签(标题说明)
        double yAxisTickCount=5,//y轴刻度数量
        double xAxisTickCount=6,//x轴刻度数量
        bool isShowXAxis=true,
        bool isShowYAxis=true,
        bool isShowChartBorderLine=false,//是否显示边框线
        Color chartBorderLineColor=const Color(0xFFEAEAEA),
        bool isShowXAxisGridLine=false,//是否显示辅助线
        Color xAxisGridLineColor=const Color(0xFFEAEAEA),
        bool isShowYAxisGridLine=false,//是否显示辅助线
        Color yAxisGridLineColor=const Color(0xFFEAEAEA),
        bool isShowLegend=true,
        LegendPosition legendPosition = LegendPosition.bottom,
        ChartAlignment legendAlignment=ChartAlignment.center,
        bool isZoom=false,//是否支持放大缩小和平移拖动
        bool isSingleTapShowTrackballInfo=false,//是否单击显示同组多条数据信息(true:单击显示多条,取消显示单条; false:长按显示同组多条,单击显示单条)
        bool isGroupShowTrackballInfo=true,//在同一块中显示多条数据信息,否则在每条中单独显示
        bool isAnimationBuild=true, //是否动画效果
        bool isEnableSelectMode=false,//是否启用选中某个条数据
        bool isEnableMultiSelection=false,//是否启用选中多个数据(否则单选)
        TextStyle? xAxisLabelStyle,//x轴文字
        TextStyle? yAxisLabelStyle,
        double? width,
        double? height,
        EdgeInsets? margin,//getEdgeInsets(left,top,right,bottom) //注意:不能有负数,即不能使用margin左移
        EdgeInsets? padding,
        String tooltipFormatString='series.name: point.y', // 默认显示信息, 'series.name, point.x, point.y', //'point.y %' //累计point.cumulative   point.size
        ChartWidgetBuilder? customTooltipWidget,//自定义显示信息
        ChartTrackballBuilder? customTrackballBehaviorWidget,//自定义显示信息
        void Function()? onNotifyLoadMoreData, //向左滑动通知加载更多数据(分批加载数据)

      }
      ){

    if(onNotifyLoadMoreData!=null){
      isZoom=false;
    }

    return XWidgetUtils.getLayoutContainer(
        width: width,
        height: height,
        margin: margin,
        padding: padding,
        child: SfCartesianChart(
          title: chartTitle??const ChartTitle(),
          plotAreaBorderWidth:isShowChartBorderLine?0.5:0,//隐藏边框线
          plotAreaBorderColor: chartBorderLineColor,
          borderWidth: 0,
          borderColor: Colors.transparent,
          enableMultiSelection: isEnableMultiSelection, //是否能选中多个
          //支持分批加载数据
          loadMoreIndicatorBuilder:onNotifyLoadMoreData==null?null:
              (BuildContext context, ChartSwipeDirection direction)
          {
            if (direction == ChartSwipeDirection.end) {
              //向左滑动
              Future<String> loadData() async {
                onNotifyLoadMoreData();
                return Future<String>.value('Completed');
              }
              return FutureBuilder<String>(
                future: loadData(), /// Adding data by updateDataSource method
                builder:
                    (BuildContext futureContext, AsyncSnapshot<String> snapShot) {
                  return snapShot.connectionState != ConnectionState.done
                      ? const CircularProgressIndicator()
                      : SizedBox.fromSize(size: Size.zero);
                },
              );
            } else {
              //向右滑动
              return SizedBox.fromSize(size: Size.zero);
            }

          },
          //图示
          legend: Legend(
            isVisible: isShowLegend,
            position: legendPosition,//显示位置
            alignment: legendAlignment,//左右位置
            //overflowMode: LegendItemOverflowMode.wrap,
            //toggleSeriesVisibility: true,//切换系列显示
          ),
          //提示(逐条点击显示)
          tooltipBehavior: TooltipBehavior(
            enable: isSingleTapShowTrackballInfo?false:true,
            header: '',
            canShowMarker: false, //对应的颜色标记
            color: const Color(0xFFFFFFFF),
            borderWidth: 0,
            borderColor: const Color(0xFFCCCCCC),
            textStyle: XStyleUtils.getTextStyle(
              color: XColorUtils.color666666,
              fontSize: 12,
              lineHeight: 1,
            ),
            //shared: true,
            activationMode: ActivationMode.singleTap, //点击显示
            format: tooltipFormatString,// 默认显示信息格式: 'series.name, point.x, point.y', //'point.y %'
            builder: customTooltipWidget,//自定义显示信息
          ),
          //提示(点击其中一条显示同组所有)
          trackballBehavior: TrackballBehavior(
            enable: true,
            tooltipDisplayMode:customTrackballBehaviorWidget!=null?TrackballDisplayMode.floatAllPoints: isGroupShowTrackballInfo?TrackballDisplayMode.groupAllPoints:TrackballDisplayMode.floatAllPoints,
            lineColor: const Color(0xFFEAEAEA),
            lineWidth: 0.5,
            tooltipAlignment: ChartAlignment.near,
            //shouldAlwaysShow:true, //注意: true一直显示不会消失,  false 点击离手即消失
            activationMode: isSingleTapShowTrackballInfo?ActivationMode.singleTap:ActivationMode.longPress, //点击显示
            tooltipSettings: InteractiveTooltip(
              enable: true,
              color: const Color(0xFFFFFFFF),
              borderRadius: 2,
              borderWidth: 0.5,
              borderColor: const Color(0xFFCCCCCC),
              textStyle: XStyleUtils.getTextStyle(
                color: XColorUtils.color666666,
                fontSize: 12,
              ),
              canShowMarker: false,
              //point.x为分组
              format: tooltipFormatString,// 'series.name, point.x, point.y',
            ),
            //注意: 自定义信息显示时,要设置TrackballDisplayMode.floatAllPoints,否则返回null, Defaults to `null` If the trackball display mode is `groupAllPoints` or `nearestPoint` it will called once and if it is `floatAllPoints`, it will be called for each point.
            builder:customTrackballBehaviorWidget,
          ),
          zoomPanBehavior: !isZoom?null:ZoomPanBehavior(
            enablePanning: true, // 启用平移
            enableDoubleTapZooming: true, // 启用双击缩放
            enablePinching: true, // 启用捏放缩放
          ),
          //X轴支持分组字符串,数字,日期,对数 Horizontal(X) axis supports Category, Numeric, Date-time, Logarithmic.
          primaryXAxis: CategoryAxis(
            isVisible:isShowXAxis,
            title: xAxisTitle??const AxisTitle(),
            minimum: 0,
            //平衡y轴的辅佐线
            majorGridLines: MajorGridLines(
              width: isShowXAxisGridLine?0.5:0,
              color: xAxisGridLineColor,
              dashArray: const [3,6],
            ), //隐藏网格辅助线
            majorTickLines: MajorTickLines(size: xAxisTickCount,width: 0.5,color: const Color(0xFFEAEAEA),),
            labelStyle:xAxisLabelStyle??XStyleUtils.textStyle_999_10(),
            //opposedPosition: false,//显示轴置顶
            //isInversed: false,//轴反转
            //labelRotation: -45,//旋转角度
          ),
          //Y轴为数值 Vertical(Y) axis always uses a numerical scale.
          primaryYAxis: NumericAxis(
            isVisible:isShowYAxis,
            title: yAxisTitle??const AxisTitle(),
            minimum: 0,
            //平衡x轴的辅佐线
            majorGridLines:  MajorGridLines(
              width: isShowYAxisGridLine?0.5:0,
              color: yAxisGridLineColor,
            ), //隐藏网格辅助线
            majorTickLines: MajorTickLines(size: yAxisTickCount),//
            labelStyle:yAxisLabelStyle??XStyleUtils.textStyle_999_10(),
          ),
          //selectionType: SelectionType.series,//选中类型
          isTransposed: isXYTransposed,//x轴与y轴换位
          //selectionGesture: ActivationMode.singleTap,//选中手势
          /*
      <ChartSeries>[
        //第1条数据: 柱状图(分组)
        ColumnSeries<dynamic, String>(
          dataSource: list1,
          xValueMapper: (dynamic data, _) => data.xValue,
          yValueMapper: (dynamic data, _) => data.yValue,
          name: 'Half population',
          //显示数据标签
          dataLabelSettings: DataLabelSettings(
            isVisible: true,
          ),
        ),
        //第2条数据: 柱状图(分组)
        ColumnSeries<dynamic, String>(
          dataSource: list1,
          xValueMapper: (dynamic data, _) => data.xValue,
          yValueMapper: (dynamic data, _) => data.yValue,
          name: 'Half population',
        ),

        //第3条数据: 柱状图(叠加)
        StackedColumnSeries<dynamic, String>(
          dataSource: list3,
          xValueMapper: (dynamic data, _) => data.xValue,
          yValueMapper: (dynamic data, _) => data.yValue,
          name: 'Half population',
        ),
       */
          series: listData.map((XChartItem item){

            //多条类型曲线
            if(item.type=='Line'){
              //折线 (多条支持分组StackedLineSeries)

              return LineSeries<XChartItemData, String>(
                dataSource: item.data??[],
                animationDuration: isAnimationBuild? 1500:0,
                name: item.name,
                xValueMapper: (XChartItemData data, index) => data.xText,
                yValueMapper: (XChartItemData data, index) => data.y,
                xAxisName:item.xAxisName,
                yAxisName:item.yAxisName,
                color: item.color,
                width: item.width??2,
                //是否启用选中模式
                selectionBehavior: SelectionBehavior(
                  enable: isEnableSelectMode,
                  selectedColor: Colors.red,
                  unselectedColor: Colors.grey,
                ),
                //修饰数据点(显示圆圈)
                //markerSettings: MarkerSettings(isVisible: true),
              );

            }else if(item.type=='LineArea'){
              //折线区域(闭合)

              return AreaSeries<XChartItemData, String>(
                dataSource: item.data??[],
                animationDuration: isAnimationBuild? 1500:0,
                name: item.name,
                xValueMapper: (XChartItemData data, index) => data.xText,
                yValueMapper: (XChartItemData data, index) => data.y,
                xAxisName:item.xAxisName,
                yAxisName:item.yAxisName,
                //是否启用选中模式
                selectionBehavior: SelectionBehavior(
                  enable: isEnableSelectMode,
                  selectedColor: Colors.red,
                  unselectedColor: Colors.grey,
                ),
                //修饰数据点(显示圆圈)
                //markerSettings: MarkerSettings(isVisible: true),
              );


            }else if(item.type=='Spline'){
              //曲线

              return SplineSeries<XChartItemData, String>(
                dataSource: item.data??[],
                animationDuration: isAnimationBuild? 1500:0,
                name: item.name,
                xValueMapper: (XChartItemData data, index) => data.xText,
                yValueMapper: (XChartItemData data, index) => data.y,
                xAxisName:item.xAxisName,
                yAxisName:item.yAxisName,
                color: item.color,
                width: item.width??2,
                //是否启用选中模式
                selectionBehavior: SelectionBehavior(
                  enable: isEnableSelectMode,
                  selectedColor: Colors.red,
                  unselectedColor: Colors.grey,
                ),
                //修饰数据点(显示圆圈)
                //markerSettings: MarkerSettings(isVisible: true),
              );

            }else if(item.type=='SplineArea'){
              //曲线区域(闭合)

              return SplineAreaSeries<XChartItemData, String>(
                dataSource: item.data??[],
                animationDuration: isAnimationBuild? 1500:0,
                name: item.name,
                xValueMapper: (XChartItemData data, index) => data.xText,
                yValueMapper: (XChartItemData data, index) => data.y,
                xAxisName:item.xAxisName,
                yAxisName:item.yAxisName,
                borderColor: item.borderColor??Colors.transparent,
                borderWidth: item.borderWidth??2.0,
                color:item.linearGradientColors!=null?null:item.color,
                gradient: item.linearGradientColors==null?null:LinearGradient(
                  colors: item.linearGradientColors!,
                  begin:item.isLinearGradientColorLeftRight?Alignment.centerLeft:Alignment.topCenter,
                  end:item.isLinearGradientColorLeftRight?Alignment.centerRight:Alignment.bottomCenter,
                ),
                borderGradient: item.borderLinearGradientColors==null?null:LinearGradient(colors: item.borderLinearGradientColors!),
                //是否启用选中模式
                selectionBehavior: SelectionBehavior(
                  enable: isEnableSelectMode,
                  selectedColor: Colors.red,
                  unselectedColor: Colors.grey,
                ),
                //修饰数据点(显示圆圈)
                //markerSettings: MarkerSettings(isVisible: true),
              );


            }else{
              //柱状图
              return ColumnSeries<XChartItemData, String>(
                dataSource: item.data??[],
                animationDuration: isAnimationBuild? 1500:0,
                name: item.name,
                xValueMapper: (XChartItemData data, index) => data.xText,
                yValueMapper: (XChartItemData data, index) => data.y,
                xAxisName:item.xAxisName,
                yAxisName:item.yAxisName,
                color: item.color,
                width: item.width??0.7,
                //是否启用选中模式
                selectionBehavior: SelectionBehavior(
                  enable: isEnableSelectMode,
                  selectedColor: Colors.red,
                  unselectedColor: Colors.grey,
                ),
                //修饰数据点(显示圆圈)
                //markerSettings: MarkerSettings(isVisible: true),
                //显示数据标签
                //dataLabelSettings: DataLabelSettings(isVisible: true,),
              );

            }

          }).toList(),
        )
    );
  }


  //x轴的数值在刻度上显示
  static Widget getWidgetChart_xAxisNumber(
      {
        required List<XChartItem> listData, //每个item为1条曲线类型
        bool isXYTransposed=false,//XY轴互换位置,横向
        ChartTitle? chartTitle,//图表图表
        AxisTitle? xAxisTitle,//x轴标签(标题说明)
        AxisTitle? yAxisTitle,//x轴标签(标题说明)
        double yAxisTickCount=5,//y轴刻度数量
        double xAxisTickCount=5,//x轴刻度数量
        bool isShowXAxis=true,
        bool isShowYAxis=true,
        double? width,
        double? height,
        EdgeInsets? margin,//getEdgeInsets(left,top,right,bottom) //注意:不能有负数,即不能使用margin左移
        EdgeInsets? padding,
      }
      ){

    return XWidgetUtils.getLayoutContainer(
        width: width,
        height: height,
        margin: margin,
        padding: padding,
        child: SfCartesianChart(
          title: chartTitle??const ChartTitle(),
          plotAreaBorderWidth:0,//隐藏边框线
          borderWidth: 0,
          borderColor: Colors.transparent,
          //图示
          legend: const Legend(
            isVisible: true,
            position: LegendPosition.bottom,//显示位置
            alignment: ChartAlignment.center,//左右位置
            //overflowMode: LegendItemOverflowMode.wrap,
            //toggleSeriesVisibility: true,//切换系列显示
          ),
          //打开工具提示
          tooltipBehavior: TooltipBehavior(
            enable: true,
            header: '',
            canShowMarker: false,
            //shared: true,
            //activationMode: ActivationMode.singleTap,
          ),
          //X轴支持分组字符串,数字,日期,对数 Horizontal(X) axis supports Category, Numeric, Date-time, Logarithmic.
          primaryXAxis: NumericAxis(
            isVisible: isShowXAxis,
            title: xAxisTitle??const AxisTitle(),
            minimum: 0,
            majorGridLines: const MajorGridLines(width: 0), //隐藏网格辅助线
            majorTickLines: MajorTickLines(size: xAxisTickCount),
            //opposedPosition: false,//显示轴置顶
            //isInversed: false,//轴反转
            //labelRotation: -45,//旋转角度
          ),
          //Y轴为数值 Vertical(Y) axis always uses a numerical scale.
          primaryYAxis: NumericAxis(
            isVisible: isShowYAxis,
            title: yAxisTitle??const AxisTitle(),
            minimum: 0,
            majorGridLines: const MajorGridLines(width: 0), //隐藏网格辅助线
            majorTickLines: MajorTickLines(size: yAxisTickCount),
          ),
          //selectionType: SelectionType.series,//选中类型
          isTransposed: isXYTransposed,//x轴与y轴换位
          //selectionGesture: ActivationMode.singleTap,//选中手势
          /*
      <ChartSeries>[
        //第1条数据: 柱状图(分组)
        ColumnSeries<dynamic, String>(
          dataSource: list1,
          xValueMapper: (dynamic data, _) => data.xValue,
          yValueMapper: (dynamic data, _) => data.yValue,
          name: 'Half population',
          //显示数据标签
          dataLabelSettings: DataLabelSettings(
            isVisible: true,
          ),
        ),
        //第2条数据: 柱状图(分组)
        ColumnSeries<dynamic, String>(
          dataSource: list1,
          xValueMapper: (dynamic data, _) => data.xValue,
          yValueMapper: (dynamic data, _) => data.yValue,
          name: 'Half population',
        ),

        //第3条数据: 柱状图(叠加)
        StackedColumnSeries<dynamic, String>(
          dataSource: list3,
          xValueMapper: (dynamic data, _) => data.xValue,
          yValueMapper: (dynamic data, _) => data.yValue,
          name: 'Half population',
        ),
       */
          series: listData.map((XChartItem item){

            //多条类型曲线
            if(item.type=='Line'){
              //折线 (多条支持分组StackedLineSeries)

              return LineSeries<XChartItemData, num>(
                dataSource: item.data??[],
                name: item.name,
                color: item.color,
                width: item.width??2,
                xValueMapper: (XChartItemData data, index) => data.xValue,
                yValueMapper: (XChartItemData data, index) => data.y,
                xAxisName:item.xAxisName,
                yAxisName:item.yAxisName,
                //修饰数据点(显示圆圈)
                //markerSettings: MarkerSettings(isVisible: true),
              );

            }else if(item.type=='LineArea'){
              //折线区域(闭合)

              return AreaSeries<XChartItemData, num>(
                dataSource: item.data??[],
                name: item.name,
                xValueMapper: (XChartItemData data, index) => data.xValue,
                yValueMapper: (XChartItemData data, index) => data.y,
                xAxisName:item.xAxisName,
                yAxisName:item.yAxisName,
                //修饰数据点(显示圆圈)
                //markerSettings: MarkerSettings(isVisible: true),
              );


            }else if(item.type=='Spline'){
              //曲线

              return SplineSeries<XChartItemData, num>(
                dataSource: item.data??[],
                name: item.name,
                color: item.color,
                width: item.width??2,
                xValueMapper: (XChartItemData data, index) => data.xValue,
                yValueMapper: (XChartItemData data, index) => data.y,
                xAxisName:item.xAxisName,
                yAxisName:item.yAxisName,
                //修饰数据点(显示圆圈)
                //markerSettings: MarkerSettings(isVisible: true),
              );

            }else if(item.type=='SplineArea'){
              //曲线区域(闭合)

              return SplineAreaSeries<XChartItemData, num>(
                dataSource: item.data??[],
                name: item.name,
                xValueMapper: (XChartItemData data, index) => data.xValue,
                yValueMapper: (XChartItemData data, index) => data.y,
                xAxisName:item.xAxisName,
                yAxisName:item.yAxisName,
                borderColor: item.borderColor??Colors.transparent,
                borderWidth: item.borderWidth??2.0,
                color:item.linearGradientColors!=null?null:item.color,
                gradient: item.linearGradientColors==null?null:LinearGradient(
                  colors: item.linearGradientColors!,
                  begin:item.isLinearGradientColorLeftRight?Alignment.centerLeft:Alignment.topCenter,
                  end:item.isLinearGradientColorLeftRight?Alignment.centerRight:Alignment.bottomCenter,
                ),
                borderGradient: item.borderLinearGradientColors==null?null:LinearGradient(colors: item.borderLinearGradientColors!),
                //修饰数据点(显示圆圈)
                //markerSettings: MarkerSettings(isVisible: true),
              );


            }else{
              //柱状图

              return ColumnSeries<XChartItemData, num>(
                dataSource: item.data??[],
                name: item.name,
                xValueMapper: (XChartItemData data, index) => data.xValue,
                yValueMapper: (XChartItemData data, index) => data.y,
                xAxisName:item.xAxisName,
                yAxisName:item.yAxisName,
                color: item.color,
                width: item.width??0.7,
                //修饰数据点(显示圆圈)
                //markerSettings: MarkerSettings(isVisible: true),
                //显示数据标签
                //dataLabelSettings: DataLabelSettings(isVisible: true,),
              );

            }

          }).toList(),
        )
    );
  }






/*
  三角形图
  https://help.syncfusion.com/flutter/pyramid-chart/overview
   */


/*
  倒三角喇叭型
  https://help.syncfusion.com/flutter/funnel-chart/overview
   */


}
